<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.27.2/axios.min.js"></script>
</head>

<body>
    <div class="container">
        <h2 class="page-header">基本使用</h2>
        <button class="btn btn-primary">发送get请求</button>
        <button class="btn btn-primary">发送post请求</button>
        <button class="btn btn-primary">发送put请求</button>
        <button class="btn btn-primary">发送delete请求</button>
    </div>
    <script>
        const btns = document.querySelectorAll('button')
        // 段子接口 https://api.apiopen.top/getJoke
        const duanzi = axios.create({
            baseURL: 'https://api.apiopen.top',
            timeout: 2000
        })
        // console.log(duanzi)
        duanzi({
            url: '/getJoke'
        }).then(res => {
            consle.log(res)
        })

        duanzi.get('getJoke').then(res => {
            console.log(res.data)
        })
    </script>
</body>

</html>